ThinkPHP5


think\Collection
library\think\Collection.php at line 20

Class Collection

Collection

public class Collection


Constructor Summary
void

__construct(mixed items)

Method Summary
static void

make(mixed items)

static bool

isEmpty()

是否为空

void

toArray()

void

all()

static

merge(mixed items)

合并数组

static static

diff(mixed items)

比较数组,返回差集

static static

flip()

交换数组中的键和值

static static

intersect(mixed items)

比较数组,返回交集

static static

keys()

返回数组中所有的键名

static mixed

pop()

删除数组的最后一个元素(出栈)

mixed

reduce(callable callback, mixed initial)

通过使用用户自定义函数,以字符串返回数组

static

reverse()

以相反的顺序返回数组。

static mixed

shift()

删除数组中首个元素,并返回被删除元素的值

static

chunk(int size, bool preserveKeys)

把一个数组分割为新的数组块.

static int

unshift(mixed value, null key)

在数组开头插入一个元素

$this

each(callable callback)

给每个元素执行个回调

static

filter(callable|null callback)

用回调函数过滤数组中的元素

static array

column(null index_key, mixed column_key)

返回数组中指定的一列

static

sort(callable|null callback)

对数组排序

static static

shuffle()

将数组打乱

static static

slice(int offset, int length, bool preserveKeys)

截取数组

static void

offsetExists(mixed offset)

void

offsetGet(mixed offset)

void

offsetSet(mixed offset, mixed value)

void

offsetUnset(mixed offset)

void

count()

void

getIterator()

void

jsonSerialize()

string

toJson(integer options)

转换当前数据集为JSON字符串

protected array

convertToArray(mixed items)

转换成数组

Constructor Detail

library\think\Collection.php at line 24

__construct

public void __construct(mixed items)

Method Detail

library\think\Collection.php at line 29

make

public static void make(mixed items)

library\think\Collection.php at line 38

isEmpty

public static bool isEmpty()

是否为空


library\think\Collection.php at line 43

toArray

public void toArray()

library\think\Collection.php at line 50

all

public void all()

library\think\Collection.php at line 61

merge

public static merge(mixed items)

合并数组


library\think\Collection.php at line 72

diff

public static static diff(mixed items)

比较数组,返回差集


library\think\Collection.php at line 82

flip

public static static flip()

交换数组中的键和值


library\think\Collection.php at line 93

intersect

public static static intersect(mixed items)

比较数组,返回交集


library\think\Collection.php at line 103

keys

public static static keys()

返回数组中所有的键名


library\think\Collection.php at line 113

pop

public static mixed pop()

删除数组的最后一个元素(出栈)


library\think\Collection.php at line 125

reduce

public mixed reduce(callable callback, mixed initial)

通过使用用户自定义函数,以字符串返回数组


library\think\Collection.php at line 135

reverse

public static reverse()

以相反的顺序返回数组。


library\think\Collection.php at line 145

shift

public static mixed shift()

删除数组中首个元素,并返回被删除元素的值


library\think\Collection.php at line 157

chunk

public static chunk(int size, bool preserveKeys)

把一个数组分割为新的数组块.


library\think\Collection.php at line 174

unshift

public static int unshift(mixed value, null key)

在数组开头插入一个元素


library\think\Collection.php at line 189

each

public $this each(callable callback)

给每个元素执行个回调


library\think\Collection.php at line 205

filter

public static filter(callable|null callback)

用回调函数过滤数组中的元素


library\think\Collection.php at line 220

column

public static array column(null index_key, mixed column_key)

返回数组中指定的一列


library\think\Collection.php at line 258

sort

public static sort(callable|null callback)

对数组排序


library\think\Collection.php at line 279

shuffle

public static static shuffle()

将数组打乱


library\think\Collection.php at line 296

slice

public static static slice(int offset, int length, bool preserveKeys)

截取数组


library\think\Collection.php at line 302

offsetExists

public static void offsetExists(mixed offset)

library\think\Collection.php at line 307

offsetGet

public void offsetGet(mixed offset)

library\think\Collection.php at line 312

offsetSet

public void offsetSet(mixed offset, mixed value)

library\think\Collection.php at line 321

offsetUnset

public void offsetUnset(mixed offset)

library\think\Collection.php at line 327

count

public void count()

library\think\Collection.php at line 333

getIterator

public void getIterator()

library\think\Collection.php at line 339

jsonSerialize

public void jsonSerialize()

library\think\Collection.php at line 350

toJson

public string toJson(integer options)

转换当前数据集为JSON字符串

Parameters:
options - json参数

library\think\Collection.php at line 366

convertToArray

protected array convertToArray(mixed items)

转换成数组


ThinkPHP5